1. Field of the Invention
The present invention relates to digital image processing, and, in particular, to alpha blending.
2. Description of the Related Art
Alpha blending is a standard technique of combining two or more input images together to generate a resulting blended image, where each pixel of the blended image is the result of taking the weighted average of the corresponding pixels of the input images. The weighted average is dictated by alpha-channel values, which may vary from pixel to pixel within an image, and from frame to frame, in the case of alpha blending of two or more video streams.
Alpha blending is typically applied to image data in a three-component color format, such as RGB24where each of the red (R), green (G), and blue (B) components is represented by an 8-bit value. The alpha channel may also be represented by 8-bit values. For example, when alpha blending two images together, each pixel of the blended image may be represented by three blended components (R.sub.b,G.sub.b,B.sub.b) generated based on straightforward weighted averaging according to the following Equations (1)-(3): ##EQU1##
where .alpha. is the alpha-channel value for the blended pixel, and (R.sub.1,G.sub.1,B.sub.1) and (R.sub.2,G.sub.2,B.sub.2) are corresponding pixels of the two input images. The resulting blended image presents a visual effect based on contributions from both input images. Alpha blending is used, for example, to simulate fades between images or scenes, or certain transparency effects (e.g., a window where the viewer sees both the view through the window as well as a partial reflection off the surface of the window).
Another standard color format for image data is the color lookup table (CLUT) format. In CLUT format, each pixel is represented by a single (e.g., 8-bit) value that is used as an index to a color lookup table which maps the index to a specific three-component (e.g., RGB24) color. An 8-bit CLUT, for example, supports up to 256 different CLUT8 indices that can map to up to 256 different RGB24 colors. In general, each CLUT8 index can map to any of the possible RGB24 colors, with little or no correlation to other CLUT8 indices and other possible RGB24 colors.
It is desirable to provide the capability to perform alpha blending of image data in CLUT format (also known as palettized image data). Unfortunately, applying an equation based on the straightforward weighted averaging of Equations (1)-(3) will typically not provide the correct results, or even an acceptable result. For example, assume that a pixel from the first input image is represented by the CLUT8 index 6, defined by the CLUT to map to a particular shade of pink. Assume further that the corresponding pixel from the second input image is represented by the CLUT8 index 8, defined by the CLUT to map to a similar but different shade of pink. If the corresponding 8-bit alpha-channel value is 128, then applying straightforward weighted averaging would produce a CLUT8 index of 7 for the corresponding blended pixel. Unfortunately, because there need be little if any correlation between CLUT8 indices, the CLUT8 index 7 can map to any RGB24 color, for example, a shade of green. Clearly, alpha blending that mixes together two shades of pink to generate a shade of green will not be useful in conventional applications of alpha blending.
The present invention is directed to an efficient and accurate method of alpha blending two or more palettized images represented in a CLUT color format.
Further objects and advantages of this invention will become apparent from the detailed description of a preferred embodiment which follows.